package middleware

import (
	"store/serializer"

	"github.com/cihub/seelog"
	"github.com/gin-gonic/gin"
)

// ServerErr 处理gin 服务器异常
func ServerErr() gin.HandlerFunc {
	return func(c *gin.Context) {
		defer func() {
			if err := recover(); err != nil {
				_ = seelog.Errorf("rest 请求异常,%s", err)
				serializer.ResponseServerErr(c, "rest请求异常")
			}
		}()
		c.Next()
	}
}
